package com.ycyun.admin.service.impl;

import com.ycyun.admin.dao.PermissionDao;
import com.ycyun.admin.model.Permission;
import com.ycyun.admin.service.PermissionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: 哦谢特谢特
 * @Date: 2018/5/21 21:25
 * @Description:
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    private static final Logger log = LoggerFactory.getLogger("adminLogger");

    @Autowired
    private PermissionDao permissionDao;


    @Override
    public void save(Permission permission) {
        permissionDao.save(permission);

        log.debug("新增菜单{}", permission.getName());
    }

    @Override
    public void update(Permission permission) {
        permissionDao.update(permission);

        log.debug("修改菜单id:{}",permission.getName());

    }

    @Override
    @Transactional
    public void delete(Long id) {

        permissionDao.deleteRolePermission(id);
        permissionDao.delete(id);
        permissionDao.deleteByParentId(id);

        log.debug("删除菜单id:{}",id);

    }
}
